package com.sojson.config.mybatis.injector;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.AbstractSqlInjector;
import com.baomidou.mybatisplus.core.injector.methods.Delete;
import com.baomidou.mybatisplus.core.injector.methods.DeleteBatchByIds;
import com.baomidou.mybatisplus.core.injector.methods.DeleteById;
import com.baomidou.mybatisplus.core.injector.methods.DeleteByMap;
import com.baomidou.mybatisplus.core.injector.methods.SelectBatchByIds;
import com.baomidou.mybatisplus.core.injector.methods.SelectById;
import com.baomidou.mybatisplus.core.injector.methods.SelectByMap;
import com.baomidou.mybatisplus.core.injector.methods.SelectCount;
import com.baomidou.mybatisplus.core.injector.methods.SelectList;
import com.baomidou.mybatisplus.core.injector.methods.SelectMaps;
import com.baomidou.mybatisplus.core.injector.methods.SelectMapsPage;
import com.baomidou.mybatisplus.core.injector.methods.SelectObjs;
import com.baomidou.mybatisplus.core.injector.methods.SelectOne;
import com.baomidou.mybatisplus.core.injector.methods.SelectPage;
import com.baomidou.mybatisplus.core.injector.methods.Update;
import com.sojson.config.mybatis.injector.impl.CustomInsert;
import com.sojson.config.mybatis.injector.impl.CustomUpdateById;

/**
 * 全局Sql注入器
 * 
 * @author liu
 * @date 2022-01-20
 */
@Component
public class CustomSqlInjector extends AbstractSqlInjector {

    @Override
    public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
        return Stream.of(
            //
            // new Insert(),
            //
            new Delete(),
            //
            new DeleteByMap(),
            //
            new DeleteById(),
            //
            new DeleteBatchByIds(),
            //
            new Update(),
            //
            // new UpdateById(),
            //
            new SelectById(),
            //
            new SelectBatchByIds(),
            //
            new SelectByMap(),
            //
            new SelectOne(),
            //
            new SelectCount(),
            //
            new SelectMaps(),
            //
            new SelectMapsPage(),
            //
            new SelectObjs(),
            //
            new SelectList(),
            //
            new SelectPage(),

            // 自定义注入器
            new CustomInsert(),
            // 自定义注入器
            new CustomUpdateById()
        //
        ).collect(Collectors.toList());
    }

}